import {Component, HostListener, OnInit} from '@angular/core';
import {Seal} from "./seal/Seal";
import {Orientation} from "./seal/enums";

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss']
})
export class AppComponent implements OnInit {
  public seal: Seal

  ngOnInit(): void {
    this.seal = new Seal()
    console.log(`init seal: ${this.seal.toString()}`)
  }

  handleOrient(val: Orientation) {
    this.seal.input(val)
  }

  @HostListener('document:keypress', ['$event'])
  globalKeyClick(event) {
    console.log(event)
    const key = event.key.toUpperCase()
    const orient = Orientation[key]
    if (orient) {
      // @ts-ignore
      this.handleOrient(orient)
    }
  }

  onResetClick() {
    this.seal.reset()
  }

  onRestartClick() {
    this.seal = new Seal()
  }
}
